﻿using ACC.Extensions.ClientBusiness;
using MahApps.Metro.Controls;
using System;
using System.Windows;

namespace ACC.Extensions.PCClient.View
{
    /// <summary>
    /// Interaction logic for MessageDialogWnd.xaml
    /// </summary>
    public partial class MessageDialogWnd : MetroWindow
    {
        public MessageDialogWnd()
        {
            InitializeComponent();
            this.Topmost = true;
        }

        public MessageDialogWnd(string title, string message)
        {
            InitializeComponent();
            this.Title = title;
            txtMessage.Text = message;
            btnCancel.Focus();
        }

        public static bool ShowDialog(string title, string message)
        {
            MessageDialogWnd wnd = new MessageDialogWnd(title, message);
            var result = wnd.ShowDialog();
            if (result.HasValue && result.Value)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
            this.Close();
        }

        private void MetroWindow_Activated(object sender, EventArgs e)
        {
            UISession.IsWndActivated = this.IsActive;
        }

        private void MetroWindow_Deactivated(object sender, EventArgs e)
        {
            UISession.IsWndActivated = this.IsActive;
        }
    }
}
